package edu.kpi.pzks2.statistics;

import java.util.List;

public class SingleResult {
    final private float time;
    final private float acceleration;
    final private float efficience;
    final private float efficienceAlgo;
    final private float overallWeight;
    
    public SingleResult(float time, float acceleration, float efficience,
            float efficienceAlgo, float overallWeight) {
        this.time = time;
        this.acceleration = acceleration;
        this.efficience = efficience;
        this.efficienceAlgo = efficienceAlgo;
        this.overallWeight = overallWeight;
    }
    
    public static SingleResult getAverage(final List<SingleResult> results) {
        float time              = 0;
        float acceleration      = 0;
        float efficience        = 0;
        float efficienceAlgo    = 0;
        float overallWeight     = 0;
        
        for (SingleResult r : results) {
            time            += r.getTime();
            acceleration    += r.getAcceleration();
            efficience      += r.getEfficience();
            efficienceAlgo  += r.getEfficienceAlgo();
            overallWeight   += r.getOverallWeight();
        }
        
        time            /= results.size();
        acceleration    /= results.size();
        efficience      /= results.size();
        efficienceAlgo  /= results.size();
        overallWeight   /= results.size();
        
        return new SingleResult(time, acceleration, efficience, efficienceAlgo, overallWeight);
    }

    public float getTime() {
        return time;
    }

    public float getAcceleration() {
        return acceleration;
    }

    public float getEfficience() {
        return efficience;
    }

    public float getEfficienceAlgo() {
        return efficienceAlgo;
    }
    
    public float getOverallWeight() {
        return overallWeight;
    }
}
